<template>
  <div id="app">
    <el-container>
      <!-- 头部 -->
      <el-header height="60px" style="background-color: #B3C0D1">
        <div class="header-left">
          <img src="@/assets/logo.png" class="logo" alt="TMS系统">
          <span class="title">TMS后台管理系统</span>
        </div>
        <div class="header-right">
          <span>您好，牛马，欢迎登录！</span>
          <el-button type="text">修改密码</el-button>
          <el-button type="text">退出系统</el-button>
        </div>
      </el-header>

      <el-container>
        <!-- 侧边栏 -->
        <el-aside width="200px">
          <el-menu background-color="#304156" text-color="#fff" active-text-color="#409EFF"
            :default-active="$route.path" router>

            <el-submenu :index="menu.menuId + ''" v-for="menu in menulist" :key="menu.menuId">
              <template #title>
                <i :class="menu.icon"></i>
                <span>{{ menu.name }}</span>
              </template>
              <!-- 子菜单循环渲染 -->
              <el-menu-item v-for="child in menu.childrenMenu" :key="child.menuId" :index="child.link">
                {{ child.name }}
              </el-menu-item>
            </el-submenu>

            <!-- 其他菜单项... -->
          </el-menu>
        </el-aside>

        <!-- 主内容区 -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    //菜单对象
    return {
      //菜单对象
      menulist: [],
    };
  }
  , methods: {

    queryMenu() {
      this.$axios.get("/api/user/queryMenu").then((res) => {
        console.log(res.data);
        this.menulist = res.data.data;
      });
    }
  }, created() {
    this.queryMenu();
  }
}
</script>

<style>
#app {
  height: 100vh;
}

.el-container {
  height: 100%;
}

.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #333;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-left .logo {
  height: 40px;
  margin-right: 10px;
}

.header-left .title {
  font-size: 20px;
  font-weight: bold;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.el-aside {
  background-color: #304156;
}

.el-menu {
  border-right: none;
}

.el-main {
  background-color: #f0f2f5;
  padding: 20px;
}
</style>
